package cn.nfwx.tv.fragment.dialog;

import android.os.Bundle;
import android.view.View;

import cn.nfwx.tv.R;
import cn.nfwx.tv.base.BaseDialogFragment;
import cn.nfwx.tv.util.ScreenUtil;

public class ReviewShareDialogFragment extends BaseDialogFragment implements View.OnClickListener {
    protected static final String EXTRA_NAME_CANCELABLE = "cancelable";
    private OnShareClickListener onShareClickListener;

    public static ReviewShareDialogFragment newInstance(boolean cancelable) {
        ReviewShareDialogFragment instance = new ReviewShareDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putBoolean(EXTRA_NAME_CANCELABLE, cancelable);
        instance.setArguments(bundle);
        return instance;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_review_share;
    }

    /**
     * 是否填满整个屏幕
     */
    protected boolean isMatchParent() {
        return true;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        findView(R.id.weix_btn).setOnClickListener(this);
        findView(R.id.pengy_btn).setOnClickListener(this);
    }

    @Override
    protected boolean isOutsideTouchable() {
        return true;
    }

    @Override
    protected boolean isTranslucentBackground() {
        return false;
    }

    @Override
    protected int getWidth() {
        return (int) (ScreenUtil.getDisplayWidth(getContext()) * 0.4);
    }

    @Override
    protected int getHeight() {
        return (int) (ScreenUtil.getDisplayHeight(getContext()) * 0.5);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.pengy_btn:
                if (onShareClickListener != null) {
                    onShareClickListener.pengy();
                }
                break;
            case R.id.weix_btn:
                if (onShareClickListener != null) {
                    onShareClickListener.weix();
                }
                break;
        }
    }

    public void setOnShareClickListener(OnShareClickListener onShareClickListener) {
        this.onShareClickListener = onShareClickListener;
    }

    public interface OnShareClickListener {
        void pengy();

        void weix();
    }
}
